import {getDictItems} from '@/api/dict'
export default {
  data() {
    return {
      id:null,//数据id
      details:{},//数据
    }
  },
  methods: {
    //进职位详情
    onInterviewInvite({id}){
      this.$navigateTo(`/pages/jobDetails/jobDetails?id=${id}`)
    },
    //人数company_scale 1
    //公司类型company_type 2
    //学历user_education 4
    //月薪position_salary 6
    //日薪day_salary 7
    getDictItemsType(type=1,key='company_scale',abc='a'){
      if(abc==='a'){
        getDictItems(key).then(res=>{
          const {code,result,success} = res;
          if(success&&code===200){
            const details = this.details
            result.map(item=>{
              if(type===1){
                if(+details.companyScale===+item.value){
                  this.$set(details,'scaleValue',item.title)
                }
              } else if(type===2){
                if(+details.positionSalary===+item.value){
                  this.$set(details,'positionSalaryValue',item.title)
                }
              }else if(type===3){
                if(+details.experience===+item.value){
                  this.$set(details,'experienceValue',item.title)
                }
              } else if(type===4){
                if(+details.education===+item.value){
                  this.$set(details,'educationValue',item.title)
                }
              }else if(type===77){
                if(+details.financeNature===+item.value){
                  this.$set(details,'financeNatureValue',item.title)
                } else {
                  this.$set(details,'financeNatureValue','未融资')
                }
              }
            })
          }
        }).catch(err=>{
          console.log (err)
        })
      } else {
        getDictItems(key).then(res=>{
          const {code,result,success} = res;
          if(success&&code===200){
            this.list.map(k=>{
              result.map(item=>{
                if(type===1){
                  if(+k.companyScale===+item.value){
                    this.$set(k,'scaleValue',item.title)
                  }
                } else if(type===2){
                  if(+k.positionSalary===+item.value){
                    this.$set(k,'positionSalaryValue',item.title)
                  }
                }else if(type===3){
                  if(+k.experience===+item.value){
                    this.$set(k,'experienceValue',item.title)
                  }
                } else if(type===4){
                  if((k.education===+item.value)|| (+k.education===+item.value)){
                    this.$set(k,'educationValue',item.title)
                  }
                }
              })
            })
            this.$forceUpdate()
          }
        }).catch(err=>{
          console.log (err)
        })
      }

    },
    getDictItemsTypes(){
      this.getDictItemsTypes1()
      this.getDictItemsType(1,'company_scale','aaa')
      this.getDictItemsType(2,'position_Salary','aaa')
      this.getDictItemsType(3,'experience','aaa')
      this.getDictItemsType(4,'user_education','aaa')
    },
    getDictItemsTypes1(){
      this.getDictItemsType()
      this.getDictItemsType(2,'position_Salary','a')
      this.getDictItemsType(3,'experience','a')
      this.getDictItemsType(4,'user_education','a')
      this.getDictItemsType(77,'finance_nature','a')
    }
  }
}
